package com.gitee.somenvm.ninerpgitem.core.resolver.parser

import com.gitee.somenvm.ninerpgitem.core.resolver.Context
import com.gitee.somenvm.ninerpgitem.core.resolver.PlaceholderResolver
import taboolib.platform.compat.replacePlaceholder

/**
 * 使用方法
 * {papi:player_name}
 * {papi:%player_name%}
 * 感觉同样没啥必要
 */
object ParserPlaceholer : PlaceholderResolver {
    override val id = "papi"
    override fun resolve(source: String, placeholder: String, context: Context): List<String> {
        val placeholder = if (!placeholder.contains("%")) "%$placeholder%" else placeholder
        val tmp = placeholder.replacePlaceholder(context.player)
        return listOf(source.replace(restore(placeholder), tmp))
    }
}